/**
 * 
 * 深圳市电联电子商务有限公司
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.service.impl;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ruipengkj.bean.TJobdeLivery;
import com.ruipengkj.commons.base.query.BaseQuery;
import com.ruipengkj.commons.base.query.PageModel;
import com.ruipengkj.dao.TJobdeLiveryDao;
import com.ruipengkj.service.TJobdeLiveryService;
/**
 * 说明：
 * 职位列表Service层接口实现
 * @Author：朱攀
 * @Date：2012-07-27
 */
@Service
public class TJobdeLiveryServiceImpl implements TJobdeLiveryService{
	@Resource
	private TJobdeLiveryDao TJobdeLiveryDao;//DAO层
	//查询所有
	@Override
	public List<TJobdeLivery> findService(TJobdeLivery entity) throws Exception {
		String hql = "select o from TJobdeLiveryDao o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		return TJobdeLiveryDao.findDao(hql, whereHQL.toString(), param, orderby);
	}
	//根据ID翻页查询
	@Override
	public PageModel<TJobdeLivery> getScrollService(int firstResult,
			int maxResult, TJobdeLivery entity) throws Exception {
		String hql = "select o from TJobdeLivery o";
		StringBuffer whereHQL = new StringBuffer();
		List<Object> param = new ArrayList<Object>();
		if (entity != null) {
//			if(entity.getTResume()!=null){
//				if(entity.getTEmployee().getName()!=null&&!entity.getTEmployee().getName().equals("")){
//					whereHQL.append("TEmployee.name").append(BaseQuery.LIKE).append("?").append(BaseQuery.AND);
//					param.add("%"+entity.getTEmployee().getName()+"%");
//				}
//			}
			if(whereHQL.length()>4)
				whereHQL.delete(whereHQL.length()-5, whereHQL.length());
		}
		LinkedHashMap<String, String> orderby = new LinkedHashMap<String, String>();
		orderby.put("happenTime", BaseQuery.DESC);
		return TJobdeLiveryDao.getScrollDao(hql, whereHQL.toString(), param, firstResult, maxResult, orderby);
	}
	//修改
	@Override
	public void modifyService(TJobdeLivery entity) throws Exception {
		TJobdeLiveryDao.modifyDao(entity);
	}
	//添加
	@Override
	public void saveService(TJobdeLivery entity) throws Exception {
		TJobdeLiveryDao.saveDao(entity);
	}
	//根据ID删除
	@Override
	public void deleteService(String id) throws Exception {
		TJobdeLiveryDao.deleteDao(id);
	}
	//根据ID查询
	@Override
	public TJobdeLivery getByIdService(String id) throws Exception {
		return TJobdeLiveryDao.getByIdDao(id);
	}
	//添加或修改
	@Override
	public void saveOrUpdateService(TJobdeLivery entity) throws Exception {
		TJobdeLiveryDao.saveOrUpdateDao(entity);
	}
	//添加返回ID
	@Override
	public Serializable saveRetService(TJobdeLivery entity) throws Exception {
		return TJobdeLiveryDao.saveRetDao(entity);
	}

	
//	@Override
//	public void addOpLogService(String log) throws Exception {
//		TOpLog opLog=new TOpLog();
//		opLog.setLogID(UUID.GenUUID15());//日志编号CHAR(15) PK
//		opLog.setOperate(log);//操作VARCHAR(256)
//		opLog.setHappenTime(new Date());//操作日期DATETIME
//		opLog.setTEmployee(ApplicationContext.EMPLOYEE);//员工
//		TOpLogDao.saveDao(opLog);
//	}
}